/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFramePrincipal.java
 *
 * Created on 15/10/2012, 08:45:19 PM
 */

package tarearonald;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author juan
 */
public class JFramePrincipal extends javax.swing.JFrame {

    /** Creates new form JFramePrincipal */
    private jInterAgregarProducto agregar;
    private InterVentas ventas;
    private jInterConsultar consultar;
    public JFramePrincipal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Escritorio = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu = new javax.swing.JMenu();
        jMenuItemAgregar = new javax.swing.JMenuItem();
        jMenuItemVentas = new javax.swing.JMenuItem();
        jMenuItemConsultar = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Escritorio.setBackground(new java.awt.Color(255, 255, 255));

        jMenu.setText("Inicio");

        jMenuItemAgregar.setText("AgregarProducto");
        jMenuItemAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAgregarActionPerformed(evt);
            }
        });
        jMenu.add(jMenuItemAgregar);

        jMenuItemVentas.setText("Ventas");
        jMenuItemVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVentasActionPerformed(evt);
            }
        });
        jMenu.add(jMenuItemVentas);

        jMenuItemConsultar.setText("Consultar Venta");
        jMenuItemConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemConsultarActionPerformed(evt);
            }
        });
        jMenu.add(jMenuItemConsultar);

        jMenuBar1.add(jMenu);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Escritorio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 642, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Escritorio, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItemAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAgregarActionPerformed
        // TODO add your handling code here:
        java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            agregar = new jInterAgregarProducto(jMenuItemAgregar);
            agregar.setIconifiable(true);
            jMenuItemAgregar.setEnabled(false);
            Escritorio.add(agregar);

        }
    });// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemAgregarActionPerformed

    private void jMenuItemVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVentasActionPerformed
        java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
                try {
                    ventas = new InterVentas(jMenuItemVentas);
                } catch (SQLException ex) {
                    Logger.getLogger(JFramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
                }
            ventas.setIconifiable(true);
            jMenuItemVentas.setEnabled(false);
            Escritorio.add(ventas);

        }
    });// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemVentasActionPerformed

    private void jMenuItemConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConsultarActionPerformed
        // TODO add your handling code here:
        java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            consultar = new jInterConsultar(jMenuItemConsultar);
            consultar.setIconifiable(true);
            jMenuItemConsultar.setEnabled(false);
            Escritorio.add(consultar);

        }
    });// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemConsultarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JFramePrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane Escritorio;
    private javax.swing.JMenu jMenu;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItemAgregar;
    private javax.swing.JMenuItem jMenuItemConsultar;
    private javax.swing.JMenuItem jMenuItemVentas;
    // End of variables declaration//GEN-END:variables

}
